package itsm.isperp.module.service.configuration;

import itsm.isperp.framework.service.TreeNodeService;
import itsm.isperp.framework.web.response.ResultMessage;
import itsm.isperp.module.entity.configuration.ConfCi;
import itsm.isperp.module.entity.configuration.ConfLocation;
import itsm.isperp.module.repository.configuration.ConfLocationMapper;
import itsm.isperp.module.utils.DbQueryUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 配置分类服务
 * 
 * @author lizx
 * @date 2013-4-29
 */
@Service
public class ConfLocationService extends TreeNodeService<ConfLocation> {

	@Autowired
	ConfLocationMapper confLocationMapper;

	@Override
	public ConfLocationMapper getRepository() {
		return confLocationMapper;
	}

	/**
	 * 删除实体及其自定义属性
	 */
	@Override
	public ResultMessage delete(String id) {

		boolean b = DbQueryUtils.exists(ConfCi.class, "location_id", id);

		if (b) {
			return ResultMessage.failure("该资产分类包含资产，不能删除！");
		}

		return super.delete(id);

	}

}
